# -*- coding: utf-8 -*-
from odoo import models, fields, api, _


class WebLayoutConfigWizard(models.TransientModel):
    _name = 'web.layout.config.wizard'
    _description = 'Web Layout Configuration Wizard'

    menu_position = fields.Selection([
        ('top', 'Top Navbar'),
        ('sidebar', 'Left Sidebar'),
    ], string='Menu Position', 
        required=True,
        help='Choose where to display the main menu')
    
    enable_multi_tab = fields.Boolean(
        string='Enable Multi-Tab Mode',
        help='Allow opening multiple pages simultaneously like browser tabs'
    )

    @api.model
    def default_get(self, fields_list):
        """Load current user's settings"""
        res = super().default_get(fields_list)
        user = self.env.user
        
        if 'menu_position' in fields_list:
            res['menu_position'] = user.menu_position or 'top'
        
        if 'enable_multi_tab' in fields_list:
            res['enable_multi_tab'] = user.enable_multi_tab or False
        
        return res

    def action_apply(self):
        """Apply settings to current user"""
        self.ensure_one()
        
        self.env.user.write({
            'menu_position': self.menu_position,
            'enable_multi_tab': self.enable_multi_tab,
        })
        
        return {
            'type': 'ir.actions.client',
            'tag': 'display_notification',
            'params': {
                'title': _('Configuration Saved'),
                'message': _('Please press Ctrl+F5 to refresh the browser to see the effects'),
                'type': 'success',
                'sticky': False,
            }
        }

